﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using FinPlusAssembler;
using FinPlusInterfaces;

namespace FinPlusBaseStructure
{
    public class FinPlusBaseStructure
    {
        //adapters
        public static IPod QuoteAdapter(string QuoteSource, IPod ReceiveAction, IPod PublishAction)
        {
            var pod = IOC.New<IPod>("QuoteSource");
            pod["QuoteSource"] = QuoteSource;
            pod["ReceiveAction"] = ReceiveAction;
            pod["PublishAction"] = PublishAction;
            return pod;
        }

        public static IPod TradeAdapter(string InstrumentType, IPod ReceiveQuoteAction, IPod ParseTradeAction, IPod ResponseAction)
        {
            var pod = IOC.New<IPod>("TradeAdapter");
            pod["InstrumentType"] = InstrumentType;
            pod["ReceiveQuoteAction"] = ReceiveQuoteAction;
            pod["ParseTradeAction"] = ParseTradeAction;
            pod["ResponseAction"] = ResponseAction;
            return pod;
        }

        //market making
        public static IPod Index(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var pod = IOC.New<IPod>("Index");
            pod["Instrument"] = Instrument;
            pod["BuySell"] = BuySell;
            pod["Level"] = Level;
            pod["Source"] = Source;
            pod["Date"] = Date;
            return pod;
        }

        public static IPod Rate(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var pod = IOC.New<IPod>("Rate");
            pod["Instrument"] = Instrument;
            pod["BuySell"] = BuySell;
            pod["Level"] = Level;
            pod["Source"] = Source;
            pod["Date"] = Date;
            return pod; 
        }

        public static IPod Price(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var pod = IOC.New<IPod>("Price");
            pod["Instrument"] = Instrument;
            pod["BuySell"] = BuySell;
            pod["Level"] = Level;
            pod["Source"] = Source;
            pod["Date"] = Date;
            return pod;
        }

        public static IPod Spread(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var pod = IOC.New<IPod>("Spread");
            pod["Instrument"] = Instrument;
            pod["BuySell"] = BuySell;
            pod["Level"] = Level;
            pod["Source"] = Source;
            pod["Date"] = Date;
            return pod;
        }

        public static IPod Setting(string IndexName, double Level, int Date)
        {
            var pod = IOC.New<IPod>("Setting");
            pod["IndexName"] = IndexName;
            pod["Level"] = Level;
            pod["Date"] = Date;
            return pod;
        }

        public static IPod Quote(string QuoteRef, string Instrument, string BuySell, double Quote, double Size, string QuoteStyle, string QuoteType, string RateType, string QuoteSource, string Counterparty) 
        {
            var pod = IOC.New<IPod>("Quote");
            pod["QuoteRef"] = QuoteRef;
            pod["Instrument"] = Instrument;
            pod["BuySell"] = BuySell;
            pod["Quote"] = Quote;
            pod["Size"] = Size;
            pod["QuoteStyle"] = QuoteStyle;
            pod["QuoteType"] = QuoteType;
            pod["RateType"] = RateType;
            pod["QuoteSource"] = QuoteSource;
            pod["Counterparty"] = Counterparty;
            return pod; 
        }

        public static IPod QuoteInterest(string Instrument, string Book, bool IsAxe, string BuySell, double Quote, double Size, string QuoteStyle, string QuoteType, string QuoteMark, string RateType, string Trader)
        {
            var pod = IOC.New<IPod>("QuoteInterest");
            pod["Instrument"] = Instrument;
            pod["Book"] = Book;
            pod["IsAxe"] = IsAxe;
            pod["BuySell"] = BuySell;
            pod["Quote"] = Quote;
            pod["Size"] = Size;
            pod["QuoteStyle"] = QuoteStyle;
            pod["QuoteType"] = QuoteType;
            pod["QuoteMark"] = QuoteMark;
            pod["RateType"] = RateType;
            pod["Trader"] = Trader;
            return pod;
        }

        public static IPod QuoteCancel(string QuoteRef) 
        {
            var pod = IOC.New<IPod>("QuoteCancel");
            pod["QuoteRef"] = QuoteRef;
            return pod;
        }

        public static IPod QuoteExecute(string QuoteRef, double Size) 
        {
            var pod = IOC.New<IPod>("QuoteExecute");
            pod["QuoteRef"] = QuoteRef;
            pod["Size"] = Size;
            return pod;
        }

        public static IPod QuoteStyle(string QuoteStyle) 
        {
            var pod = IOC.New<IPod>("QuoteStyle");
            pod["QuoteStyle"] = QuoteStyle;
            return pod;
        }

        public static IPod QuoteType(string QuoteType) 
        {
            var pod = IOC.New<IPod>("QuoteType");
            pod["QuoteType"] = QuoteType;
            return pod;
        }

        public static IPod QuoteMark(string QuoteMark)
        {
            var pod = IOC.New<IPod>("QuoteMark");
            pod["QuoteMark"] = QuoteMark;
            return pod;
        }

        public static IPod QuoteSource(string QuoteSource, string User, string Location) 
        {
            var pod = IOC.New<IPod>("QuoteSource");
            pod["QuoteSource"] = QuoteSource;
            pod["User"] = User;
            pod["Location"] = Location;
            return pod;
        }

        public static IPod CounterpartyQuoteTier(string Counterparty, string InstrumentType, double Adjustment)
        {
            var pod = IOC.New<IPod>("QuoteTier");
            pod["Counterparty"] = Counterparty;
            pod["InstrumentType"] = InstrumentType;
            pod["Adjustment"] = Adjustment;
            return pod;
        }

        public static IPod Instrument(string Instrument, string Ccy, string LinkedCurve, string InstrumentName, string InstrumentType, string RateType, double ChgMin, double SizeMin, double SizeMax, double ShockUnit) 
        {
            var pod = IOC.New<IPod>("Instrument");
            pod["Instrument"] = Instrument;
            pod["Ccy"] = Ccy;
            pod["LinkedCurve"] = LinkedCurve;
            pod["InstrumentName"] = InstrumentName;
            pod["InstrumentType"] = InstrumentType;
            pod["RateType"] = RateType;
            pod["ChgMin"] = ChgMin;
            pod["SizeMin"] = SizeMin;
            pod["SizeMax"] = SizeMax;
            pod["ShockUnit"] = ShockUnit;
            return pod;
        }

        public static IPod InstrumentSpread(string Instrument, string SpreadName, string Spread, string SpreadType, bool IsMktToMkt, double BuyAdj, double SellAdj, double Weight, string Trader)
        {
            var pod = IOC.New<IPod>("InstrumentSpread");
            pod["Instrument"] = Instrument;
            pod["SpreadName"] = SpreadName;
            pod["Spread"] = Spread;
            pod["SpreadType"] = SpreadType;
            pod["Weight"] = Weight;
            pod["IsMktToMkt"] = IsMktToMkt;
            pod["BuyAdj"] = BuyAdj;
            pod["SellAdj"] = SellAdj;
            pod["Trader"] = Trader;
            return pod;
        }

        public static IPod InstrumentType(string InstrumentType)
        {
            var pod = IOC.New<IPod>("InstrumentType");
            pod["InstrumentType"] = InstrumentType;
            return pod;
        }

        public static IPod RateType(string RateType)
        {
            var pod = IOC.New<IPod>("RateType");
            pod["RateType"] = RateType;
            return pod;
        }

        public static IPod Ccy(string Ccy, string Name) 
        {
            var pod = IOC.New<IPod>("Ccy");
            pod["Ccy"] = Ccy;
            pod["Name"] = Name;
            return pod;
        }

        public static IPod BuySell(string BuySell) 
        {
            var pod = IOC.New<IPod>("BuySell");
            pod["BuySell"] = BuySell;
            return pod;
        }

        public static IPod SpreadType(string SpreadType)
        {
            var pod = IOC.New<IPod>("SpreadType");
            pod["SpreadType"] = SpreadType;
            return pod;
        }

        public static IPod BizConv(string BizConv)
        {
            var pod = IOC.New<IPod>("BizConv");
            pod["BizConv"] = BizConv;
            return pod;
        }

        public static IPod DayCount(string DayCount)
        {
            var pod = IOC.New<IPod>("DayCount");
            pod["DayCount"] = DayCount;
            return pod;
        }

        public static IPod Holidays(string Holidays)
        {
            var pod = IOC.New<IPod>("Holidays");
            pod["Holidays"] = Holidays;
            return pod;
        }

        public static IPod Freq(string Freq)
        {
            var pod = IOC.New<IPod>("Freq");
            pod["Freq"] = Freq;
            return pod;
        }

        public static IPod PayRec(string PayRec)
        {
            var pod = IOC.New<IPod>("PayRec");
            pod["PayRec"] = PayRec;
            return pod;
        }

        public static IPod CurveName(string CurveName, string CurveType)
        {
            var pod = IOC.New<IPod>("CurveName");
            pod["CurveName"] = CurveName;
            pod["CurveType"] = CurveType;
            return pod;
        }

        public static IPod CurveType(string CurveType)
        {
            var pod = IOC.New<IPod>("CurveName");
            pod["CurveName"] = CurveType;
            return pod;
        }

        //templates
        public static IPod VanillaSwapBuild(string Instrument, string CurveName, int SettlementDays, bool EndOfMonth, string Maturity, string Index, double Spread, string FixLegFrq, string FltLegFrq, string FixLegConv, string FltLegConv, string FixLegDayCount, string FltLegDayCount, string Holidays)
        {
            var pod = IOC.New<IPod>("VanillaSwapBuild");
            pod["Instrument"] = Instrument;
            pod["CurveName"] = CurveName;
            pod["SettlementDays"] = SettlementDays;
            pod["EndOfMonth"] = EndOfMonth;
            pod["Maturity"] = Maturity;
            pod["Index"] = Index;
            pod["Spread"] = Spread;
            pod["FixLegFrq"] = Index;
            pod["FltLegFrq"] = Index;
            pod["FixLegConv"] = Index;
            pod["FltLegConv"] = Index;
            pod["FixLegDayCount"] = Index;
            pod["FltLegDayCount"] = Index;
            pod["Holidays"] = Index;
            return pod;
        }

        public static IPod ForwardRateAgreementBuild(string Instrument, string CurveName, int SettlementDays, string Start, string Maturity, string Index, string DayCount, string BizConv, string Holidays)
        {
            var pod = IOC.New<IPod>("ForwardRateAgreementBuild");
            pod["Instrument"] = Instrument;
            pod["CurveName"] = CurveName;
            pod["SettlementDays"] = SettlementDays;
            pod["Start"] = Start;
            pod["Maturity"] = Maturity;
            pod["Index"] = Index;
            pod["DayCount"] = DayCount;
            pod["BizConv"] = BizConv;
            pod["Holidays"] = Holidays;
            return pod;
        }

        public static IPod DepositLoanBuild(string Instrument, string CurveName, int SettlementDays, string Maturity, string Index, string DayCount, string BizConv, string Holidays)
        {
            var pod = IOC.New<IPod>("DepositLoanBuild");
            pod["Instrument"] = Instrument;
            pod["CurveName"] = CurveName;
            pod["SettlementDays"] = SettlementDays;
            pod["Maturity"] = Maturity;
            pod["Index"] = Index;
            pod["DayCount"] = DayCount;
            pod["BizConv"] = BizConv;
            pod["Holidays"] = Holidays;
            return pod;
        }

        public static IPod ZCMBuild(string Instrument, string Maturity, int SettlementDays, string DayCount, string BizConv, string Holidays)
        {
            var pod = IOC.New<IPod>("ZCMBuild");
            pod["Instrument"] = Instrument;
            pod["Maturity"] = Maturity;
            pod["SettlementDays"] = SettlementDays;
            pod["BizConv"] = BizConv;
            pod["Holidays"] = Holidays;
            return pod;
        }

        public static IPod IRFutureBuild(string Instrument, string CurveName, int StartDate, int FutMonths, string DayCount, string BizConv, string Holidays)
        {
            var pod = IOC.New<IPod>("IRFutureBuild");
            pod["Instrument"] = Instrument;
            pod["CurveName"] = CurveName;
            pod["StartDate"] = StartDate;
            pod["FutMonths"] = FutMonths;
            pod["DayCount"] = DayCount;
            pod["BizConv"] = BizConv;
            pod["Holidays"] = Holidays;
            return pod;
        }

        public static IPod CreditDefaultSwapBuild(string Instrument, string CurveName, int SettlementDays, string Maturity, string PremFreq, string PremConv, string PayConv, string DayCount, string Holidays)
        {
            var pod = IOC.New<IPod>("CreditDefaultSwapBuild");
            pod["Instrument"] = Instrument;
            pod["CurveName"] = CurveName;
            pod["SettlementDays"] = SettlementDays;
            pod["Maturity"] = Maturity;
            pod["PremFreq"] = PremFreq;
            pod["PremConv"] = PremConv;
            pod["PayConv"] = PayConv;
            pod["Holidays"] = Holidays;
            return pod;
        }

        public static IPod YieldCurveBuild(string CurveName, string Ccy, int NumDepo, int NumFut, int NumFra, int NumSwap, string Index, string DayCount, string Tolerance, string Holidays)
        {
            var pod = IOC.New<IPod>("YieldCurveBuild");
            pod["CurveName"] = CurveName;
            pod["Ccy"] = Ccy;
            pod["NumDepo"] = Ccy;
            pod["NumFut"] = NumFut;
            pod["NumFra"] = NumFra;
            pod["NumSwap"] = NumSwap;
            pod["Index"] = Index;
            pod["DayCount"] = DayCount;
            pod["Tolerance"] = Tolerance;
            pod["Holidays"] = Holidays;
            return pod;
        }

        public static IPod DefaultCurveBuild(string CurveName, string Ccy, int NumSpread, string CreditName, double RecoveryRate, string DayCount, string Holidays)
        {
            var pod = IOC.New<IPod>("DefaultCurveBuild");
            pod["CurveName"] = CurveName;
            pod["Ccy"] = Ccy;
            pod["NumSpread"] = NumSpread;
            pod["CreditName"] = CreditName;
            pod["RecoveryRate"] = RecoveryRate;
            pod["DayCount"] = DayCount;
            pod["Holidays"] = Holidays;
            return pod;
        }

        public static IPod BondCurveBuild(string CurveName, string Ccy, int NumZCM, int NumBond, string DayCount, double Tolerance, string Holidays)
        {
            var pod = IOC.New<IPod>("CurveName");
            pod["DayCount"] = DayCount;
            pod["Tolerance"] = Tolerance;
            pod["Holidays"] = Holidays;
            return pod;
        }

        public static IPod IndexBuild(string IndexName, string CurveName, string IndexType, string Tenor)
        {
            var pod = IOC.New<IPod>("IndexBuild");
            pod["IndexName"] = IndexName;
            pod["CurveName"] = CurveName;
            pod["IndexType"] = IndexType;
            pod["Tenor"] = Tenor;
            return pod;
        }

        //permissions
        public static IPod Permission(string User, string Name, string BeanName, string BeanValue, bool CanRead, bool CanWrite)
        {
            var pod = IOC.New<IPod>("Permission");
            pod["User"] = User;
            pod["Name"] = Name;
            pod["BeanName"] = BeanName;
            pod["BeanValue"] = BeanValue;
            pod["CanRead"] = CanRead;
            pod["CanWrite"] = CanWrite;
            return pod;
        }

        //info
        public static IPod Application(string Application, string Description, string Owner)
        {
            var pod = IOC.New<IPod>("Application");
            pod["Application"] = Application;
            pod["Description"] = Description;
            pod["Owner"] = Owner;
            return pod;
        }

        //business structure
        public static IPod Location(string Location, string Country, string Region)
        {
            var pod = IOC.New<IPod>("Location");
            pod["Location"] = Location;
            pod["Country"] = Country;
            pod["Region"] = Region;
            return pod;
        }

        public static IPod Department(string Department, string Location)
        {
            var pod = IOC.New<IPod>("Department");
            pod["Department"] = Department;
            pod["Location"] = Location;
            return pod;
        }

        public static IPod Desk(string Desk, string Department)
        {
            var pod = IOC.New<IPod>("Desk");
            pod["Desk"] = Desk;
            pod["Department"] = Department;
            return pod;
        }

        public static IPod Book(string Book, string Desk, string Department, string Location)
        {
            var pod = IOC.New<IPod>("Book");
            pod["Desk"] = Desk;
            pod["Department"] = Department;
            pod["Location"] = Location;
            return pod;
        }

        public static IPod User(string User, string UserName, string Desk, string Location)
        {
            var pod = IOC.New<IPod>("User");
            pod["User"] = User;
            pod["UserName"] = UserName;
            pod["Desk"] = Desk;
            pod["Location"] = Location;
            return pod;
        }

        //country structure
        public static IPod Region(string Region)
        {
            var pod = IOC.New<IPod>("Region");
            pod["Region"] = Region;
            return pod;
        }

        public static IPod Country(string Country, string Region)
        {
            var pod = IOC.New<IPod>("Country");
            pod["Country"] = Country;
            pod["Region"] = Region;
            return pod;
        }

        //company structure
        public static IPod Counterparty(string Counterparty, string LongName, string Identifier, string DefaultCollateralCurve, string Country, string Sector, string Region, string InternalRating, string MoodysRating, string SnPRating)
        {
            var pod = IOC.New<IPod>("Counterparty");
            pod["Counterparty"] = Counterparty;
            pod["LongName"] = Counterparty;
            pod["Identifier"] = Identifier;
            pod["Country"] = Country;
            pod["DefaultCollateralCurve"] = DefaultCollateralCurve;
            pod["Sector"] = Sector;
            pod["Region"] = Region;
            pod["InternalRating"] = InternalRating;
            pod["MoodysRating"] = MoodysRating;
            pod["SnPRating"] = SnPRating;
            return pod;
        }

        public static IPod Sector(string Sector)
        {
            var pod = IOC.New<IPod>("Sector");
            pod["Sector"] = Sector;
            return pod;
        }

        public static IPod InternalRating(string InternalRating, int Index)
        {
            var pod = IOC.New<IPod>("InternalRating");
            pod["InternalRating"] = InternalRating;
            pod["Index"] = Index;
            return pod;
        }

        public static IPod MoodysRating(string MoodysRating, int Index)
        {
            var pod = IOC.New<IPod>("MoodysRating");
            pod["MoodysRating"] = MoodysRating;
            pod["Index"] = Index;
            return pod;
        }

        public static IPod SnPRating(string SnPRating, int Index)
        {
            var pod = IOC.New<IPod>("SnPRating");
            pod["SnPRating"] = SnPRating;
            pod["Index"] = Index;
            return pod;
        }

        //admin
        public static IPod PodMap(string Group, string Name)
        {
            var pod = IOC.New<IPod>("podtionMap");
            pod["Group"] = Group;
            pod["Name"] = Name;
            return pod;
        }
    }
}
